package system;

import Main.Parameters;
import java.io.File;

/**
 * Move file task to specified place in settings.ini
 * @author zem
 */
public class FileTaskMove {

    public FileTaskMove() {
        String FileTask=""+Parameters.TaskFolder+Parameters.TaskName[Parameters.CurrentTaskNumber];
        if(!Parameters.TaskFailed){ //task done
        File path = new File(new PathName(Parameters.MoveDoneTaskTo, 1).name); //folder where to put files
        if (!path.exists()) {
            path.mkdirs(); //create folder with all parent folders
        }
        if (path.exists()) { //if folder exists
            new File(FileTask).renameTo(new File(new PathName(Parameters.MoveDoneTaskTo, 1).name + Parameters.TaskName[Parameters.CurrentTaskNumber]));
        } else { //in else case error printing and add extension
            Parameters.message_parameter[0] = Parameters.MoveDoneTaskTo;
            Parameters.message_parameter[1] = Parameters.TaskName[Parameters.CurrentTaskNumber];
            System.out.println(new Message("er0002").message);
           new FileTaskRename(); //rename

        }
    }else
    {
     File path = new File(new PathName(Parameters.MoveFailedTaskTo, 1).name); //folder where to put files
        if (!path.exists()) {
            path.mkdirs(); //create folder with all parent folders
        }
        if (path.exists()) { //if folder exists
            new File(FileTask).renameTo(new File(new PathName(Parameters.MoveFailedTaskTo, 1).name + Parameters.TaskName[Parameters.CurrentTaskNumber]));
        } else { //in else case error printing and add extension
            Parameters.message_parameter[0] = Parameters.MoveFailedTaskTo;
            Parameters.message_parameter[1] = Parameters.TaskName[Parameters.CurrentTaskNumber];
            System.out.println(new Message("er0002").message);
            new FileTaskRename(); //rename

        }



    }
}
}
